/*
 * produceEnergy() test
 * 
 * 
 */
package Tests;

import static org.junit.Assert.*;
import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;

import Model.Mule;
import Model.Player;
import Model.Tile;

public class tileTest_ProduceEnergy {
	
	/**
	 * player, tile, and mule fixtures
	 */
	Player thePlayer;
	Tile theTile; 
	Mule theMule;
	
	
	/**
	 * this method is run before each test, constructing the player
	 * NOTE: Starting quantities for Flapper are: M=1000, F=8, E=4, Ore=0
	 */
	@Before
	public void setUp() throws Exception {
		thePlayer = new Player();
		thePlayer.setRace("Flapper");
	}
	
	/**
	 * Testing produceEnergy() when theTile holds a non-energy mule
	 */
	@Test
	public void notEnergyMule() {
		theTile = new Tile("R"); // type will not impact result
		theMule = new Mule("Food"); // non-energy mule
		
		// set fields
		theTile.setOwner(thePlayer);
		theTile.setMule(theMule);
		
		// produce
		theTile.produceEnergy();
		
		// test whether player received no energy (they start with 4)
		Assert.assertEquals( "Incorrect production", 4, theTile.getOwner().getEnergy() );
		
	}
	
	/**
	 * Testing produceEnergy() with an Energy mule on a River tile.
	 * The player should receive 1 unit of energy, since the tile produces 2
	 * but the mule uses 1 to do the work.
	 */
	@Test
	public void riverTile() {
		theTile = new Tile("R"); 
		theMule = new Mule("Energy"); // energy mule
		
		// set fields
		theTile.setOwner(thePlayer);
		theTile.setMule(theMule);
		
		// produce
		theTile.produceEnergy();
		
		// test whether player received 1 unit of energy (they start with 4, river produces 2, and 
		// theMule uses 1 for production
		Assert.assertEquals( "Incorrect production", 5, theTile.getOwner().getEnergy() );
	
	}
	
	/**
	 * Testing produceEnergy() with an energy mule on a Plain tile.
	 * The player should receive 2 units of energy, since the tile produces 3 
	 * but the mule uses 1 to do the work.
	 */
	@Test
	public void plainTile() {
		theTile = new Tile("P"); 
		theMule = new Mule("Energy"); // energy mule
		
		// set fields
		theTile.setOwner(thePlayer);
		theTile.setMule(theMule);
		
		// produce
		theTile.produceEnergy();
		
		// test whether player received 2 units of energy (they start with 4, plain produces 3, and 
		// theMule uses 1 for production
		Assert.assertEquals( "Incorrect production", 6, theTile.getOwner().getEnergy() );
	
	}
	
	/**
	 * Testing produceEnergy() with an energy mule on an ore tile.
	 * The player should receive 0 units of energy, since the tile produces 1 
	 * but the mule uses 1 to do the work.
	 */
	@Test
	public void mountainTile() {
		theTile = new Tile("M1"); 
		theMule = new Mule("Energy"); // energy mule
		
		// set fields
		theTile.setOwner(thePlayer);
		theTile.setMule(theMule);
		
		// produce
		theTile.produceEnergy();
		
		// test whether player received 0 units of energy (they start with 4, M1 produces 1, and 
		// theMule uses 1 for production
		Assert.assertEquals( "Incorrect production", 4, theTile.getOwner().getEnergy() );
	
	}
	
	
	
	
	
	
	

}
